package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.StrategyCatalog;
import cn.wolfcode.wolf2w.service.IStrategyCatalogService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.service.ITravelService;
import cn.wolfcode.wolf2w.service.impl.DestinationServiceImpl;
import cn.wolfcode.wolf2w.service.impl.RegionServiceImpl;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/destinations")
public class DestinationController {

    @Autowired
    private RegionServiceImpl regionService;

    @Autowired
    private DestinationServiceImpl destinationService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;

    @GetMapping("/hotRegion")
    private Object hotRegion() {
        return JsonResult.success(regionService.queryHotRegion());
    }

    @GetMapping("/search")
    private Object search(String regionId) {
        return JsonResult.success(destinationService.queryDestByRegionIdForApi(regionId));
    }

    @GetMapping("/detail")
    private Object detail(String id) {
        return JsonResult.success(destinationService.get(id));
    }

    @GetMapping("/toasts")
    private Object toasts(String parentId) {
        return JsonResult.success(destinationService.queryToasts(parentId));
    }

    @GetMapping("/catalogs")
    private Object catalogs(String destId) {

        List<StrategyCatalog> catalogs = strategyCatalogService.queryCatalogsByDestId(destId);

        return JsonResult.success(catalogs);
    }

    @GetMapping("/travels/viewnumTop3")
    private Object travelsViewnumTop3(String destId){

        return JsonResult.success(travelService.queryViewnumTop3(destId));
    }

    @GetMapping("/strategies/viewnumTop3")
    private Object strategiesViewnumTop3(String destId) {
        return JsonResult.success(strategyService.queryViewnumByDestId(destId));
    }
    @GetMapping("/list")
    private Object list(){
        return JsonResult.success(destinationService.list());
    }





}
